//
//  HDDeclare.m
//  HDWuDaDaoServiceCenter
//
//  Created by HDNiuKuiming on 2017/4/7.
//  Copyright © 2017年 HDNiuKuiming. All rights reserved.
//

#import "HDDeclare.h"
#import "sys/utsname.h"
#import <SystemConfiguration/CaptiveNetwork.h>
#import <sys/utsname.h>
#import "FMDB.h"
#import "HD_HSP_Exhibit_Model.h"
#import "HD_HSP_Broadcast.h"

@interface HDDeclare ()
@property(strong,nonatomic)FMDatabase *dataBase;
@property(strong,nonatomic)FMDatabase *newsDataBase;
@end


@implementation HDDeclare

#pragma mark
#pragma mark -------- Init Methods --------

+ (id)sharedDeclare
{
    static id sharedDeclare;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedDeclare = [[self alloc] init];
    });
    return sharedDeclare;
}

-(FMDatabase *)dataBase
{
    if (!_dataBase) {
        NSString *tempPath = [NSString stringWithFormat:@"%@/Filemanage.sqlite",self.catch_path];
        _dataBase = [FMDatabase databaseWithPath:tempPath];
    }
    return _dataBase;
}

-(FMDatabase *)newsDataBase
{
    if (!_newsDataBase) {
        NSString *tempPath = [NSString stringWithFormat:@"%@/myNews.sqlite",self.catch_path];
        _newsDataBase = [FMDatabase databaseWithPath:tempPath];
    }
    return _newsDataBase;
}


#pragma mark - 新闻数据

-(NSArray*)giveMeNewsData
{
    NSMutableArray *arr = [NSMutableArray array];
    
    if ([self.newsDataBase open]) {//查询
        
        NSString *tempStr = [NSString stringWithFormat:@"SELECT * FROM %@",@"news"];
        FMResultSet * rs = [self.newsDataBase executeQuery:tempStr];

        while ([rs next]) {
            
            HD_HSP_Broadcast *model = [[HD_HSP_Broadcast alloc]init];
            
            model.identifier = [rs stringForColumn:@"identifier"];
            model.title = [rs stringForColumn:@"title"];
            model.content = [rs stringForColumn:@"content"];
            model.time = [rs stringForColumn:@"time"];
            model.html_path = [rs stringForColumn:@"html_path"];
            model.list_img = [rs stringForColumn:@"list_img"];
            model.status = [rs stringForColumn:@"status"];
            
            
            [arr addObject:model];
        }
        
        [self.newsDataBase close];
    }
    
    return arr;
}

-(void)delegateNewsWith:(NSString *)identifier
{
    if ([self.newsDataBase open]) {//删除数据
        
        
        
        NSString *deleteSql = [NSString stringWithFormat:
                               
                               @"delete from %@ where %@ = '%@'",
                               
                               @"news", @"identifier", identifier];
        
        BOOL res = [self.newsDataBase executeUpdate:deleteSql];
        
        
        
        if (!res) {
            
            NSLog(@"error when delete db table");
            
        } else {
            
            NSLog(@"success to delete db table");
            
        }
        
        [self.newsDataBase close];
    }
}


-(void)makeSeenWith:(NSString *)identifier
{
    if ([self.newsDataBase open]) {//修改数据
        
        NSString *temp = [NSString stringWithFormat:@"UPDATE %@ SET %@ = '%@' WHERE %@ = '%@'",@"news",@"status",@"old",@"identifier",identifier];
        
        BOOL res = [self.newsDataBase executeUpdate:temp];
        
        if (!res) {
            
            NSLog(@"error when update db table");
            
        } else {
            
            NSLog(@"success to update db table");
            
        }
        
        [self.newsDataBase close];
    }
}

-(void)addANewWith:(HD_HSP_Broadcast*)broadcast
{
    
    if ([self.newsDataBase open]) {//添加数据
        
        NSString *sqlStr = @"";
        FMResultSet *set  = [self.newsDataBase executeQuery:[self findNews:broadcast.identifier]];
        if ([set next]) {
            sqlStr = [NSString stringWithFormat:@"UPDATE news SET identifier ='%@',title = '%@',content = '%@',time = '%@',html_path = '%@',list_img = '%@',status = '%@' WHERE identifier ='%@'",broadcast.identifier,broadcast.title,broadcast.content,broadcast.time,broadcast.html_path,broadcast.list_img,broadcast.status,broadcast.identifier];
        }
        else {
            sqlStr = [NSString stringWithFormat:@"INSERT INTO news (identifier, title, content, time,html_path,list_img, status) VALUES ('%@', '%@', '%@', '%@','%@','%@', '%@')",broadcast.identifier,broadcast.title,broadcast.content,broadcast.time,broadcast.html_path,broadcast.list_img,broadcast.status];
        }
        
        BOOL res = [self.newsDataBase executeUpdate:sqlStr];
        
        if (res) {
            
            NSLog(@"success to insert db table");
            
        } else {
            
            NSLog(@"error when insert db table");
            
        }
        
        [self.newsDataBase close];
        
    }
}

-(NSString*)findNews:(NSString *)identifier{
    return [NSString stringWithFormat:@"SELECT identifier FROM news WHERE identifier = '%@'", identifier];
}



#pragma mark - 展品数据

-(NSArray*)giveMeUnitData
{
    NSMutableArray *arr = [NSMutableArray array];
    
    if ([self.dataBase open]) {//查询
        
        NSString *tempStr = [NSString stringWithFormat:@"SELECT * FROM %@_Unit",self.language.uppercaseString];
        FMResultSet * rs = [self.dataBase executeQuery:tempStr];
        
        while ([rs next]) {
            
            HD_HSP_Exhibit_Model *model = [[HD_HSP_Exhibit_Model alloc]init];
            
            model.type = [rs intForColumn:@"type"];
            model.name = [rs stringForColumn:@"title"];
            
            [arr addObject:model];
        }
        
        [self.dataBase close];
    }
    
    return arr;
}

-(NSArray*)giveMeZhanTingData
{
    NSMutableArray *arr = [NSMutableArray array];
    
    if ([self.dataBase open]) {//查询
        
        NSString *tempStr = [NSString stringWithFormat:@"SELECT * FROM %@",@"MAP_Config"];
        FMResultSet * rs = [self.dataBase executeQuery:tempStr];
        
        while ([rs next]) {
            
            HD_HSP_Exhibit_Model *model = [[HD_HSP_Exhibit_Model alloc]init];
            
            model.type = [rs intForColumn:@"type"];
            model.name = [rs stringForColumn:@"name"];
            model.c_subname = [rs stringForColumn:@"c_subname"];
            model.tingFloor = [rs intForColumn:@"floor"];
            model.width = [rs doubleForColumn:@"width"];
            model.height = [rs doubleForColumn:@"height"];
            
            [arr addObject:model];
        }
        
        [self.dataBase close];
    }
    
    return arr;

}



//
-(NSArray*)giveMeExhibitData
{
    NSMutableArray *arr = [NSMutableArray array];
    
    if ([self.dataBase open]) {//查询
        
        NSString *tempStr = [NSString stringWithFormat:@"SELECT * FROM %@",self.language];
        FMResultSet * rs = [self.dataBase executeQuery:tempStr];
        
        while ([rs next]) {
            
            HD_HSP_Exhibit_Model *model = [[HD_HSP_Exhibit_Model alloc]init];

            model.autoNum = [rs stringForColumn:@"autoNum"];
            model.FileNum = [rs stringForColumn:@"fileNum"];
            model.FileName = [rs stringForColumn:@"title"];
            model.unitNum = [rs stringForColumn:@"sort"];

            
            [arr addObject:model];
        }
        
        [self.dataBase close];
    }
    
    return arr;
}

-(NSArray*)giveMeBoutiqueData
{
    NSMutableArray *arr = [NSMutableArray array];
    
    if ([self.dataBase open]) {//查询
        
        NSString *tableNameStr = [NSString stringWithFormat:@"%@_Boutique",self.language.uppercaseString];
        NSString *tempStr = [NSString stringWithFormat:@"SELECT * FROM %@",tableNameStr];
        FMResultSet * rs = [self.dataBase executeQuery:tempStr];
        
        while ([rs next]) {
            
            HD_HSP_Exhibit_Model *model = [[HD_HSP_Exhibit_Model alloc]init];
            
            model.FileNum = [rs stringForColumn:@"fileNum"];
            model.FileName = [rs stringForColumn:@"title"];
            
            [arr addObject:model];
        }
        
        [self.dataBase close];
    }
    
    return arr;
}

- (id)init
{
    self = [super init];

    if(self){
        _beaconFlag = NO;
        
        self.language = kLanuage_CHINESE;
        
        NSString *webMapPath = [NSString stringWithFormat:@"%@/Resource/WebMap/", kCachePath];
        _nowMuseumID = @"0001";
        [self createMapPath:webMapPath];
    }

    return self;
}

+ (BOOL)isValidBeacon:(NSInteger)beaconNum
{
    BOOL isValid = NO;
    if (beaconNum > 0 && beaconNum < 1000)
        isValid = YES;
    
    return isValid;
}

- (void)createMapPath:(NSString *)webMapPath {
    NSFileManager *fileManager = [NSFileManager defaultManager];
    
    BOOL isDir = NO;
    NSError *isError = nil;
    BOOL existed = [fileManager fileExistsAtPath:webMapPath isDirectory:&isDir];
    if (isDir == YES && existed == YES) {
        [fileManager removeItemAtPath:webMapPath error:&isError];
    }
    
    [fileManager createDirectoryAtPath:webMapPath withIntermediateDirectories:YES attributes:nil error:nil];
}

- (NSString *)getUserPhoneID{
    NSString *userID = [[NSUserDefaults standardUserDefaults] objectForKey:kFirst_Machine_ID];
    
//    if (userID == nil)
//        userID = @"iOS0000001";
    
    return userID;        
}

- (NSString*)deviceVersion
{
    // 需要#import "sys/utsname.h"
    struct utsname systemInfo;
    uname(&systemInfo);
    NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
    if ([deviceString isEqualToString:@"iPhone4,1"])    return @"iPhone4S";
    if ([deviceString isEqualToString:@"iPhone5,2"]||[deviceString isEqualToString:@"iPhone5,4"])    return @"iPhone5";
    if ([deviceString isEqualToString:@"iPhone6,2"])    return @"iPhone5S";
    if ([deviceString isEqualToString:@"iPhone7,1"]||[deviceString isEqualToString:@"iPhone7,2"])    return @"iPhone6";
    if ([deviceString isEqualToString:@"iPhone8,1"]||[deviceString isEqualToString:@"iPhone8,2"])    return @"iPhone6s";
    return deviceString;
}

- (NSString*)nowLanguage
{
    return _language;
} // 当前语种，大写

- (void)setLanguageType:(Language_Type)languageType
{
    _languageType = languageType;
    
    switch (languageType) {
        case kLanguage_Type_Chinese:
            [self setLanguage:kLanuage_CHINESE];
            break;
        case kLanguage_Type_English:
            [self setLanguage:kLanuage_ENGLISH];
            break;
        case kLanguage_Type_Japanese:
             [self setLanguage:kLanuage_JAPANESE];
            break;
        case kLanguage_Type_Korean:
            [self setLanguage:kLanuage_KOREAN];
            break;
   
        default:
            [self setLanguage:kLanuage_CHINESE];
            break;
    }
    //保存翻译词条
    [self saveTranslateDic];
}

-(void)setLanguage:(NSString *)language
{
    
    if (_language!=nil)
    {
        _language = nil;
    }
    _language = language;
    if ([_language isEqualToString:kLanuage_CHINESE])
    {
        self.museumName = @"辽宁省博物馆";
        //提示框（多个地方用到）
        self.alertTitle = @"提示";
        self.alertCancel = @"取 消";
        self.cameraUnavailable = @"没有权限访问相机，请到设置页面修改相机访问权限。";
        
        self.alertOK = @"确定";
        self.InvalidInput = @"无此编号展品";
        self.versionTips = @"当前版本是V";
        self.sizeIsZero = @"暂无讲解";
        self.download_Size = @"大小";
        
        self.alertBack = @"返回";
        self.latestVersion = @"已是最近版本，无需更新！";
        self.NewVersions = @"检测到软件有新版本，是否更新？";
        self.NewDatabase = @"检测到有新的展品信息，是否更新？";
        
        // 首屏：
        self.introduce = @"展览简介";
        self.introduction = @"展馆简介";
        self.museumRelics = @"馆藏精品";
        self.strategy = @"参观攻略";
        self.mapGuide = @"地图导览";
        self.autoGuide = @"自动导览";
        
        //下载与解压：
        self.downloading = @"正在下载，请稍候";
        self.downloadFailed = @"资源下载失败！";
        self.downloadNetFailed = @"资源下载失败，请检查网络设置！";
        self.downloadBackTip = @"资源正在下载，确定要停止下载并返回吗？";
        self.connectFailed = @"服务器连接失败！";
        self.downloadSizeZero = @"抱歉，未获取到服务器资源。";
        self.instralling = @"正在安装资源文件...";
        self.underConstruction = @"正在建设中...";
        
        //导览：
        self.noExhibits = @"没有展品！";
        self.autoGuideSearch = @"请输入数字编号";
        self.QRCodePage = @"二维码扫描";
        self.autoGuideNumber = @"数字编号：";
        self.strategy_guide = @"参观须知";
        self.strategy_ticket = @"票务信息";
        self.strategy_traffic= @"交通信息";
        self.strategy_surroundings= @"周边环境";
        self.strategy_phone= @"电 话";
        self.strategy_blog= @"微博微信";
        self.strategy_website= @"官方网站";
        
        //设置：
        self.settingLanguage = @"语言设置";
        self.settingNowVersion = @"当前版本";
        self.settingRenewVersion = @"软件更新";
        self.settingResourceTips = @"是否下载全部展品资源？";
        self.allResourceTips = @"讲解资源已经存在，是否重新下载全部展品资源？";
        self.settingRenewResource = @"下载全部讲解资源";
        self.autoLocation = @"自动讲解";
        self.setting = @"设 置";
        
        // 交互
        self.Questionnaire = @"问卷调查";
        self.lastPageThanks = @"问卷调查完毕，已是最后一页，感谢您的参与！";
        self.lastPage = @"已是最后一页！";
        self.myFriend = @"我的同伴";
        self.deleteNews = @"删 除";
        
        //SOS：
        self.sosSendSuccess = @"求助发送成功";
        self.sosPage = @"求 助";
        self.sosLost = @"迷路";
        self.sosHurt = @"受伤";
        self.sosOther = @"其他";
        self.SOS = @"求 助";
        self.SOSSuceed = @"发送成功";
        self.outsideService = @"您现在的智慧服务为馆外模式，不能向馆内进行紧急求助";
        
        //调查问卷：
        self.Feedback = @"意见反馈";
        self.netSurveyOver = @"问卷调查完毕，已是最后一页，感谢您的参与！";
        self.netSurveyLastPage = @"已是最后一页！";
        self.nullcontent = @"发送内容不能为空";
        self.feedbacksuceed = @"提交成功";
        self.feedbackName = @"请输入您的姓名";
        self.feedbackEmail = @"请输入您的邮箱";
        self.feedbackContent = @"在此留下您的宝贵意见";
        self.feedEmailError = @"邮箱格式错误，请输入正确的邮箱地址！";
        
        //组群：
        self.joinGroup = @"加入现有群组";
        self.registerGroup = @"注册新的群组";
        self.registerFailed = @"注册失败！";
        self.myGroupNumber = @"当前群组号为：";
        self.myGroupTotalPersion = @"本组人数：";
        self.myGroupQuit = @"确定要退出本组吗？";
        
        self.guideRoute = @"路线推荐";
        self.registerSucceed = @"注册群组号成功，您当前的群组号为:";
        self.joinNumberNeed = @"请输入您要加入的群组号";
        self.outsideGroup = @"您现在的智慧服务为馆外模式,不能使用馆内定位功能";
        self.joinFailed = @"加入失败";
        self.noLocationInfo = @"暂无当前成员的馆内位置信息";
        
        //个人中心：
        self.myinformation = @"我的信息";
        self.input = @"请输入新的昵称";
        self.thenews = @"最新消息";
        self.yourInside = @"您现在的智慧服务为馆内模式";
        self.yourOutside = @"您现在的智慧服务为馆外模式";
        self.nameNotNil = @"昵称不能为空，不能包含空格";
        
        self.nameLabel = @"昵称:";
        self.groupLabel = @"组号:";
        self.minePage = @"个人中心";
        self.mineInfo = @"个人信息";
        self.othersNickName = @"游客";
        self.mineCategory = @"组别：";
        
        //资讯：
        self.noMessage = @"没有新消息通知";
        self.detailString = @"资讯详情";
        self.informationNewNotice = @"最新资讯";
        self.systemNotice = @"系统通知";
        self.systemWelcome = @"您好，欢迎使用辽宁省博物馆智慧服务系统！";
        self.floorTitle = @"一楼";
    }
    
    else if ([_language isEqualToString:kLanuage_ENGLISH])
    {
        self.museumName = @"Wuhan Revolution Museum";
        //提示框（多个地方用到）
        self.alertTitle = @"Alert";
        self.alertCancel = @"Cancel";
        self.alertOK = @"OK";
        self.InvalidInput = @"Item not found of this number";
        self.versionTips = @"Current Version - V";
        self.sizeIsZero = @"Interpretation not available";
        
        self.download_Size = @"Size";
        self.alertBack = @"Back";
        self.cameraUnavailable = @"Camera No Authorization!";
        
        self.latestVersion = @"This is the latest version, no need to update!";
        self.NewVersions = @"New version detected, update now?";
        self.NewDatabase = @"New exhibit information detected, update now?";
        
        //首屏：
        self.introduce = @"Intro";
        self.introduction = @"OverView";
        self.museumRelics = @"Boutique";
        self.strategy = @"Tips";
        self.mapGuide = @"Map Service";
        self.autoGuide = @"Audio Guide";
        
        //下载与解压：
        self.downloading = @"Downloading";
        self.downloadFailed = @"Download failed!";
        self.downloadNetFailed = @"Resource download failed, check the network settings!";
        self.downloadBackTip = @"Resources are being downloaded, will you stop downloading and back?";
        self.connectFailed = @"Server connection failed!";
        self.downloadSizeZero = @"Sorry, no resources.";
        self.instralling = @"Installing resource file...";
        self.underConstruction = @"Under construction...";
        
        //导览：
        self.noExhibits = @"No exhibits!";
        self.autoGuideSearch = @"Enter exhibit number";
        self.QRCodePage = @"QR Code Scan";
        self.autoGuideNumber = @"Exhibit number：";
        self.autoGuideNumber = @"Exhibit number：";
        self.strategy_guide = @"Visit Guide";
        self.strategy_ticket = @"Ticket";
        self.strategy_traffic= @"Traffic Route";
        self.strategy_surroundings= @"Surroundings";
        self.strategy_phone= @"Telephone";
        self.strategy_blog= @"Micro-blog";
        self.strategy_website= @"Website";
        
        //设置：
        self.settingLanguage = @"Language";
        self.settingNowVersion = @"Current Version";
        self.settingRenewVersion = @"Software Update";
        self.settingResourceTips = @"Are you sure you wish update all resources?";
        self.settingRenewResource = @"Download All Resources";
        self.allResourceTips = @"Are you sure delete and download resources?";
        self.autoLocation = @"Auto Guide";
        self.setting = @"Set Up";
        
        // 交互
        self.Questionnaire = @"Questionnaire";
        self.lastPageThanks = @"Here is the end, thank you!";
        self.lastPage = @"Here is the end!";
        self.myFriend = @"Companion";
        self.deleteNews = @"Delete";
        
        //SOS：
        self.sosSendSuccess = @"SOS message sent successfully";
        self.sosPage = @"Help";
        self.sosLost = @"Lost";
        self.sosHurt = @"Injured";
        self.sosOther = @"Other";
        self.SOS = @"Help";
        self.SOSSuceed = @"Sent successfully";
        self.outsideService = @"You are now in the Outdoor Mode, thereby unable to call inside museum for help";
        
        
        //调查问卷：
        self.Questionnaire = @"Questionnaire";
        self.Feedback = @"Feedback";
        self.netSurveyOver = @"The end of questionnaire. Thanks for your participation! ";
        self.netSurveyLastPage = @"Here is the last page!";
        self.nullcontent = @"Empty message cannot be sent";
        self.feedbacksuceed = @"Submitted successfully";
        self.feedbackName = @"Please enter your name";
        self.feedbackEmail = @"Please enter your email address";
        self.feedbackContent = @"Leave your comments here";
        self.feedEmailError = @"The mailbox format error, please enter the correct email address!";
        
        //组群：
        self.joinGroup = @"Join existing group";
        self.registerGroup = @"Register a new group";
        self.registerFailed = @"Register failed";
        self.myGroupNumber = @"Your group number:";
        self.myGroupTotalPersion = @"Total:";
        self.myGroupQuit = @"Are you sure you want to quit this group?";
        
        self.guideRoute = @"Recommended Routes";
        self.registerSucceed = @"Registration successful. Your current group number is: ";
        self.joinNumberNeed = @"Enter the group number you intend to join in.";
        
        self.outsideGroup = @"You are now in the Outdoor Mode, thereby unable to use the system of positioning inside museum.";
        self.joinFailed = @"Failed to join";
        self.noLocationInfo = @"Positional information of current members inside museum not available" ;
        
        //个人中心：
        self.myinformation = @"My information";
        self.input = @"Please enter a new nickname";
        self.thenews = @"The latest news";
        self.yourInside = @"You are now in the Indoor Mode";
        self.yourOutside = @"You are now in the Outdoor Mode";
        self.nameLabel = @"Name:";
        self.groupLabel = @"Group:";
        self.minePage = @"User Center";
        self.mineInfo = @"Personal Information";
        
        self.othersNickName = @"Visitor";
        self.mineCategory = @"Group: ";
        self.nameNotNil = @"Name can't be empty";
        
        //资讯：
        self.noMessage = @"No new message";
        self.detailString = @"Information in detail";
        self.informationNewNotice = @"Information";
        self.systemNotice = @"System notice";
        self.systemWelcome = @"Welcome to use the Smart Service System in Liaoning Museum!";
        self.floorTitle = @"Floor 1";
    }
    
    else if ([_language isEqualToString:kLanuage_JAPANESE])
    {
        self.museumName = @"";
        //提示框（多个地方用到）
        self.alertTitle = @"ヒント";
        self.alertCancel = @"取り消し";
        
        self.alertOK = @"はい";
        self.InvalidInput = @"この番号がありません";
        self.versionTips = @"バージョン：V";
        self.sizeIsZero = @"暫時の解説";
        self.download_Size = @"大きさ";
        
        self.alertBack = @"戻る";
        self.latestVersion = @"は最近バージョン更新必要ない！";
        self.NewVersions = @"新バージョン検出、更新しますか？";
        self.NewDatabase = @"新データベースリソース検出、今更新しますか？";
        self.cameraUnavailable = @"アクセス権限がないカメラは、ページを設けて改正カメラアクセス権限。";
        
        // 首屏：
        self.introduce = @"紹介";
        self.introduction = @"紹介";
        self.strategy = @"観覧ポイント";
        self.museumRelics = @"所蔵の精品";
        self.mapGuide = @"マップ";
        self.autoGuide = @"音声ガイド";
        
        //下载与解压：
        self.downloading = @"ダウンロードの中で";
        self.downloadFailed = @"下載失敗。";
        self.downloadNetFailed = @"資源ダウンロードしてくださいチェックのネットワーク設定！";
        self.downloadBackTip = @"資源をダウンロードして、ダウンロードを行うには、必ずダウンロードを行うか？";
        self.connectFailed = @"サーバーが接続に失败し！";
        self.downloadSizeZero = @"申し訳ありませんが、未をサーバー資源。";
        self.instralling = @"ロード中、暫くお待ちください...";
        self.underConstruction = @"建設中...";
        
        //导览：
        self.noExhibits = @"この番号がありません";
        self.autoGuideSearch = @"数字の番号";
        self.QRCodePage = @"QRコードスキャナー";
        self.autoGuideNumber = @"数字の番号：";
        self.strategy_guide = @"観覧注意事項";
        self.strategy_ticket = @"チケット情報";
        self.strategy_traffic= @"交通情報";
        self.strategy_surroundings= @"週辺環境";
        self.strategy_phone= @"問い合わせ先";
        self.strategy_blog= @"マイクロブログ";
        self.strategy_website= @"公式サイト";
        
        //设置：
        self.settingLanguage = @"言語選択";
        self.settingNowVersion = @"バージョン情報";
        self.settingRenewVersion = @"软件更新";
        self.settingResourceTips = @"新バージョン検出、更新しますか？";
        self.allResourceTips = @"新バージョン検出、更新しますか？";
        self.settingRenewResource = @"リソース更新";
        self.autoLocation = @"自動ガイド";
        self.setting = @"設置され";
        self.myFriend = @"同行者";
        
        //SOS：
        self.sosSendSuccess = @"援助を求める情報が出されました。";
        self.sosPage = @"緊急救助";
        self.sosLost = @"道に迷って";
        self.sosHurt = @"怪我";
        self.sosOther = @"その他";
        self.SOS = @"緊急援助";
        self.SOSSuceed = @"送信済み";
        self.outsideService = @"今のサービスは館外パターンで、館内へ緊急援助を求めることができません。";
        
        //调查问卷：
        self.Questionnaire = @"アンケート調査";
        self.Feedback = @"ご意見";
        self.netSurveyOver = @"アンケートは以上です。ご協力、どうもありがとうございました。";
        self.netSurveyLastPage = @"最後のページです！";
        self.nullcontent = @"内容はなければなりません。";
        self.feedbacksuceed = @"提出しました";
        self.feedbackName = @"あなたのお名前を入力してください";
        self.feedbackEmail = @"あなたのメールアドレスを入力してください";
        self.feedbackContent = @"ここにあなたの貴重な意見を殘して";
        self.feedEmailError = @"メールアドレスフォーマットミスのメールアドレスを入力してください！";
        
        //组群：
        self.joinGroup = @"現有のチームの加入";
        self.registerGroup = @"新しいグループを登録";
        self.registerFailed = @"登録できません";
        self.myGroupNumber = @"現在の群号を：";
        self.myGroupTotalPersion = @"総人数：";
        self.guideRoute = @"ルート推薦";
        self.myGroupQuit = @"必ず名目に本組ですか？";
        
        self.registerSucceed = @"登録成功、グループの番号は:";
        self.joinNumberNeed = @"加入するグループの番号を入力していください。";
        self.outsideGroup = @"今のサービスは館外パターンで、館内へ緊急援助を求めることができません。";
        self.joinFailed = @"加入できません";
        self.noLocationInfo = @"当該メンバーの館内位置情報はありません。";
        
        //个人中心：
        self.myinformation = @"私のニュース";
        self.input = @"新しいニックネームを入力してください";
        self.thenews = @"最新ニュース";
        self.yourInside = @"今のサービスは館内パターンです";
        self.yourOutside = @"今のサービスは館外パターンです";
        self.nameLabel = @"別名:";
        self.groupLabel = @"何組:";
        self.minePage = @"個人センター";
        self.mineInfo = @"個人情報";
        
        self.othersNickName = @"観光客";
        self.mineCategory = @"組：";
        self.nameNotNil = @"名前は空にできません";
        
        //资讯：
        self.noMessage = @"新着情報はありません。";
        self.detailString = @"詳しい情報";
        self.informationNewNotice = @"博物館案内";
        self.systemNotice = @"システム通知";
        self.systemWelcome = @"こんにちは、ようこそ、遼寧省博物館！";
        self.deleteNews = @"削除";
        self.floorTitle = @"1階";
    }
    else if ([_language isEqualToString:kLanuage_KOREAN])
    {
        //提示框（多个地方用到）
        self.alertTitle = @"도움말";
        self.alertCancel = @"취소";
        self.alertOK = @"확정";
        
        self.InvalidInput = @"해당된 전시품 넘버가 존재하지 않습니다";
        self.versionTips = @"현재의 버번은 V 입니다";
        self.sizeIsZero = @"임시 안내 말씀이 없습니다";
        self.download_Size = @"크기";
        self.alertBack = @"되돌아가기";
        self.noExhibits = @"전시품이 없습니다！";
        
        self.latestVersion = @"이미 요즘 버전 업데이트 필요 없다!";
        self.NewVersions = @"소프트웨어가 새로운 버전이 있다고 검색되었는데 업그레이드하시겠습니까？";
        self.NewDatabase = @"새로운 전시품 정보가 검색되었는데 업그레이드하시겠습니까？";
        self.cameraUnavailable = @"권한이 거부되었습니다 방문 카메라, 어서 안으로 설정 페이지 수정 카메라 접근 권한.";
        
        //首屏：
        self.introduce = @"전시관 설명";
        self.strategy = @"방문 공략";
        self.mapGuide = @"지도 안내";
        self.autoGuide = @"자동가이드";
        self.museumRelics = @"소장 정품";
        
        //下载与解压：
        self.downloading = @"다운로드중입니다";
        self.downloadFailed = @"다운로드 수 없습니다.";
        self.downloadNetFailed = @"자원 다운로드 실패를 네트워크 설정을 확인하십시오!";
        self.downloadBackTip = @"자원 다운로드 중, 복귀 중지할 것이다 다운, 확실히 그만 다운로드?";
        self.connectFailed = @"서버 연결 실패!";
        self.downloadSizeZero = @"죄송합니다. 아직 가져오기 서버에 자원.";
        self.instralling = @"파일 설치중입니다...";
        self.underConstruction = @"건설 중...";
        
        //导览：
        self.noExhibits = @"전시품이 없습니다！";
        self.autoGuideSearch = @"전시품 넘버를 입력해 주십시오";
        self.QRCodePage = @"QR코드 스캔";
        self.autoGuideNumber = @"전시품 넘버";
        
        //设置：
        self.settingLanguage = @"언어 설치";
        self.settingNowVersion = @"현재 버전";
        self.settingRenewVersion = @"소프트웨어 업그레이드";
        self.settingResourceTips = @"업데이트 확인 할 모든 자원?";
        self.allResourceTips = @"업데이트 확인 할 모든 자원?";
        self.settingRenewResource = @"자원 업데이트";
        self.autoLocation = @"자동 안내";
        self.setting = @"시스템 설치";
        self.myFriend = @"동반자";
        
        //SOS：
        self.sosSendSuccess = @"구조 도움 요청이 발송되었습니다";
        self.sosPage = @"도움말";
        self.sosLost = @"길을 잃었다";
        self.sosHurt = @"다치다";
        self.sosOther = @"기타";
        self.SOS = @"도움말";
        self.SOSSuceed = @"성공적으로 발송하였습니다";
        self.outsideService = @"현제 사용중인 서비스 페턴은 관할 지역 밖의 페턴이기 때문에 긴급 도움 요청을 제출할 수 없습니다";
        
        
        //调查问卷：
        self.Questionnaire = @"설문 조사";
        self.Feedback = @"피드백";
        self.netSurveyOver = @"설문 조사는 이것으로 끝났습니다. 이것은 마지막 페이지입니다. 참여해 주셔서 감합니다！";
        self.netSurveyLastPage = @"마지막 페이지입니다！";
        self.nullcontent = @"빈 내용을 발송할 수 없습니다";
        self.feedbacksuceed = @"성공적으로 제출하였습니다";
        self.feedbackName = @"당신의 이름을 입력하십시오";
        self.feedbackEmail = @"입력하십시오 사서함";
        self.feedbackContent = @"당신은 이 남긴 귀중한 의견을";
        self.feedEmailError = @"메일박스 형식 오류 입력하십시오. 정확한 이메일 주소!";
        
        //组群：
        self.joinGroup = @"기존의 그룹에 가입합니다";
        self.registerGroup = @"새 그룹을 등록합니다";
        self.registerFailed = @"등록 실패하였습니다";
        self.myGroupNumber = @"현재 그룹의 군 호 위해:";
        self.myGroupTotalPersion = @"전체 인원:";
        self.guideRoute = @"노선 -";
        self.myGroupQuit = @"확실히 이 그룹의 종료할 수 있습니까?";
        
        self.registerSucceed = @"그룹을 성공적으로 등록하였습니다.등록한 그룹의 넘버는 다음과 같습니다";
        self.joinNumberNeed = @"가입하려는 그룹의 넘버를 입력해 주십시오";
        self.outsideGroup = @"현제 사용중인 서비스 페턴은 관할 지역 밖의 페턴이기 때문에 관할 지역 내부에서만 사용할 수 있는 위치 추적 기능을 사용할 수 없습니다.";
        self.joinFailed = @"가입 실패하였습니다";
        self.noLocationInfo =@"현재 멤버의 위치가 등록되지 않았습니다.";
        
        //个人中心：
        self.myinformation = @"나의 정보";
        self.input = @"새로운 애칭을 입력해 주십시오";
        self.thenews = @"최신 소식";
        self.yourInside = @"지금 체육관 안에 사용 지혜 서비스 시스템";
        self.yourOutside = @"지금 체육관 외 서비스 시스템 사용 지혜";
        self.nameLabel = @"애칭:";
        self.groupLabel = @"그룹 넘버:";
        self.minePage = @"개인정보";
        self.mineInfo = @"개인 정보";
        
        self.othersNickName = @"관광객";
        self.mineCategory = @"그룹별：";
        self.nameNotNil = @"이름이 비어 수 없다";
        
        //资讯：
        self.noMessage = @"새소식이 없습니다";
        self.detailString = @"상세한 정보";
        self.informationNewNotice = @"최신 뉴스";
        self.systemNotice = @"시스템 통지";
        self.systemWelcome = @"안녕하세요, 까지 요녕성 박물관 참관을 환영합니다!";
        self.deleteNews = @"삭제";
        self.floorTitle = @"1층";
    }
}

- (Language_Type)languageIndex
{
    Language_Type languageType = kLanguage_Type_Chinese;
    if ([_language isEqualToString:kLanuage_ENGLISH])
    {
        languageType = kLanguage_Type_English;
    }
    
    else if ([_language isEqualToString:kLanuage_JAPANESE])
    {
        languageType = kLanguage_Type_Japanese;
    }
    
    else if ([_language isEqualToString:kLanuage_KOREAN])
    {
        languageType = kLanguage_Type_Korean;
    }
    else if ([_language isEqualToString:kLanuage_FRENCH])
    {
        languageType = kLanguage_Type_French;
    }
    else if ([_language isEqualToString:kLanuage_GERMANY])
    {
        languageType = kLanguage_Type_Germany;
    }
    else if ([_language isEqualToString:kLanuage_SPANISH])
    {
        languageType = kLanguage_Type_Spanish;
    }
    
    return languageType;
}

- (NSString*)nowLanguageIndexStr // 当前语种1,2,3,4...
{
    return  [NSString stringWithFormat:@"%i", self.languageIndex];
}

- (BOOL)isRouteShowMode
{
    return self.routeArray.count > 0;
}

#define kWLAN_SSID_Name  @"jinshayizhi"
#define kWLAN_Ip_Address @"http://47.93.81.30/yanshi/jsbwg"
#define kNet_Ip_Address  @"http://192.168.10.158/lnbwg/"

//#define kWLAN_Ip_Address @"http://192.168.10.158/jsbwg"
//#define kNet_Ip_Address  @"http://192.168.10.158/jsbwg"

+ (NSString *)IP_Request_Header // 根据内外网获取http请求的前缀
{
    NSString *ipPrefixStr = kNet_Ip_Address;
    if ([[HDDeclare sharedDeclare] isWLANNet] == YES)
        ipPrefixStr = kWLAN_Ip_Address;
    
    return ipPrefixStr;
}

- (BOOL)isWLANNet
{
    NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
    LOG(@"Supported interfaces: %@", ifs);
    id info = nil;
    for (NSString *ifnam in ifs) {
        info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
        LOG(@"%@ => %@", ifnam, info);
        if (info && [info count]) { break; }
    }
    NSString *ssid = [info objectForKey:@"SSID"];
    
    return [ssid.uppercaseString isEqualToString:kWLAN_SSID_Name.uppercaseString];
}

-(NSString *)catch_path
{
    return [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask, YES) objectAtIndex: 0] stringByAppendingString:@"/Resource"];
}

#pragma mark
#pragma mark ---------- 翻译 ----------

- (void)saveTranslateDic{
    if (self.translateDic) {
        self.translateDic = nil;
    }
    NSString *plistFile = [NSString stringWithFormat:@"%@",[_language lowercaseString]];
    if ([plistFile isEqualToString:@""]) {
        return;
    }
    self.translateDic = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:plistFile ofType:@"plist"]];
}

- (NSString *)getTranslate:(NSString*)originalString{
    NSString *resultStr = [self.translateDic objectForKey:[NSString stringWithFormat:@"%@",originalString]];
    if (resultStr == nil)
        resultStr = @"  ";
    
    return resultStr;
}

+ (NSString *)UIString:(NSString *)keyStr
{
    return [[self sharedDeclare] getTranslate:keyStr];
}

#pragma mark
#pragma mark -------- Is All Resource --------

// 判断资源是否过半了，提示下载
- (void)judgeIsResourceAll
{
    _isResourceAll = [self isAllMp3];
}

-(BOOL)isAllMp3
{
    // 递归遍历
    NSString *path = [NSString stringWithFormat:@"%@/Resource/%@",kCachePath, [_language uppercaseString]];
    
    //遍历这个目录的第一种方法：（深度遍历，会递归枚举它的内容）
    NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:path];
    
    LOG(@"1.Contents of %@:",path);
    UInt32 i=0;
    while ((path = [dirEnum nextObject]) != nil)
    {
        if ([path hasSuffix:@"mp3"])
        {
            i++;
            LOG(@"%@",path);
        }
        BOOL flag;
        [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&flag];
        if(flag == YES)
            [dirEnum skipDescendants];
    }
    
    return (i >= _resArray.count/2);
}

@end
